'\" te
.\" Copyright (c) 2008, Sun Microsystems, Inc.  All Rights Reserved.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH DI_DEVLINK_DUP 3DEVINFO "May 15, 2008"
.SH NAME
di_devlink_dup, di_devlink_free \- copy and free a devlink object
.SH SYNOPSIS
.LP
.nf
\fBcc\fR [ \fIflag\fR... ] \fIfile\fR... \fB-ldevinfo\fR [ \fIlibrary\fR... ]
#include <libdevinfo.h>

\fBdi_devlink_t\fR \fBdi_devlink_dup\fR(\fBdi_devlink_t\fR \fIdevlink\fR);
.fi

.LP
.nf
\fBint\fR \fBdi_devlink_free\fR(\fBdi_devlink_t\fR \fIdevlink\fR);
.fi

.SH PARAMETERS
.sp
.ne 2
.na
\fB\fIdevlink\fR\fR
.ad
.RS 11n
An opaque handle to a devlink.
.RE

.SH DESCRIPTION
.sp
.LP
Typically, a \fBdi_devlink_t\fR object is only accessible from within the scope
of the \fBdi_devlink_walk\fR(3DEVINFO) callback function. The
\fBdi_devlink_dup()\fR function allows the callback function implementation to
make a duplicate copy of the \fBdi_devlink_t\fR object. The duplicate copy is
valid and accessible until \fBdi_devlink_free()\fR is called.
.sp
.LP
The \fBdi_devlink_dup()\fR function returns a copy of a \fIdevlink\fR object.
The \fBdi_devlink_free()\fR function frees this copy.
.SH RETURN VALUES
.sp
.LP
Upon successful completion, \fBdi_devlink_dup()\fR returns a copy of the
\fIdevlink\fR object passed in.  Otherwise, \fINULL\fR is returned and
\fBerrno\fR is set to indicate the error.
.sp
.LP
Upon successful completion, \fBdi_devlink_free()\fR returns 0. Otherwise, -1 is
returned and \fBerrno\fR is set to indicate the error.
.SH ERRORS
.sp
.LP
The \fBdi_devlink_dup()\fR and \fBdi_devlink_free()\fR functions will fail if:
.sp
.ne 2
.na
\fB\fBEINVAL\fR\fR
.ad
.RS 10n
The \fIdevlink\fR argument is not a valid handle.
.RE

.sp
.LP
The \fBdi_devlink_dup()\fR function can set \fBerrno\fR to any error value that
can also be set by \fBmalloc\fR(3C).
.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(7)  for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Interface Stability	Committed
_
MT-Level	Safe
.TE

.SH SEE ALSO
.sp
.LP
.BR malloc (3C),
.BR di_devlink_init (3DEVINFO),
.BR di_devlink_path (3DEVINFO),
.BR di_devlink_walk (3DEVINFO),
.BR libdevinfo (3LIB),
.BR attributes (7)
